{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set menu = 'admin_coin_records' %}

{% block main %}

    <form id="coin-orders-search-form" class="form-inline well well-sm" action="" method="get" novalidate>

        <div class="form-group"> 
          <select class="form-control" name="type" onchange="submit();"> 
               {% set options = {'inflow':'充值记录','outflow':'消费记录','':'全部记录'} %}
            {{ select_options(options, app.request.get('type')) }} 
          </select> 
        </div> 
        <div class="form-group"> 
          <select class="form-control" name="createdTime" onchange="submit();"> 
               {% set options = {'oneWeek':'最近一周','oneMonth':'最近一个月','threeMonths':'最近三个月','all':'全部记录',} %}
            {{ select_options(options, app.request.get('createdTime')) }} 
          </select> 
        </div> 

        <div class="form-group">
            <select class="form-control" name="keywordType">
          {{ select_options(dict('coinRecordType'), app.request.query.get('keywordType'), '--选择类型--') }}
        </select>
        </div>

        <div class="form-group">
            <input type="text" id="keyword" name="keyword" class="form-control" value="{{ app.request.query.get('keyword') }}" placeholder="关键词">
        </div>

      <button class="btn btn-primary">搜索</button>
      <a class="btn btn-primary" href="{{ path('admin_bill_export_csv',{
      cashType:cashType,
      createdTime:app.request.get('createdTime'),
      type:app.request.get('type'),      
      keywordType:app.request.query.get('keywordType'),
      keyword:app.request.query.get('keyword'),
      })}}">导出结果</a>
    </form>
  
    <p class="text-muted">
      <span class="mrl">网校余额：<strong class="amount-num">{{amounts|default(0)}}</strong> {{ setting('coin.coin_name') }}</span>
      <span class="mrl">充值：<strong class="inflow-num">{{inflow|default(0)}}</strong> {{ setting('coin.coin_name') }}</span>
      <span class="mrl">消费：<strong class="outflow-num">{{outflow|default(0)}}</strong> {{ setting('coin.coin_name') }}</span>
    </p>
    <div class="table-responsive">
      <table class="table table-striped">
        <tr>
          <th>流水号</th>
          <th>名称</th>
          <th>用户</th>
          <th>成交时间</th>
          <th class="text-right" style="padding-right: 50px;">收支</th>
        </tr>

       {% for cash in cashes %}
       <tr>
            <td>{{cash.sn}}</td>
            <td>{{cash.name}}<br>
                <span class="text-muted text-sm">订单号：{{cash.orderSn}}</span></td>
            <td>   <a target="_blank" href="{{ path('user_show', {id:cash.userId}) }}">
            {{users[cash.userId].nickname}}</a></td>
            <td>{{cash.createdTime|date('Y-m-d H:i:s')}}</td>     
            {% if cash.type =="inflow" %}
            <td class="text-right" style="color:#1bb974;padding-right: 50px;">
               {{cash.amount}} 
            </td>
            {% endif %}
            {% if cash.type =="outflow" %}
            <td  class="text-right" style="color:#ff7b0e;padding-right: 50px;">
               -&nbsp;{{cash.amount}}               
            </td>
            {% endif %}
       </tr>
       {% endfor %}
      </table>
    </div>
 {{ web_macro.paginator(paginator) }}

{% endblock %}